﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SharepointUpload
{
    public partial class TreeDesign : UserControl
    {
        SPService.IntraLinksSoapClient webService = new SPService.IntraLinksSoapClient();
        DataSourceTranslation ds = new DataSourceTranslation();
        public TreeDesign()
        {
            InitializeComponent();
            webService.GetAllWebsCompleted += new EventHandler<SPService.GetAllWebsCompletedEventArgs>(webService_GetAllWebsCompleted);
            webService.GetAllWebsAsync();
        }

        void webService_GetAllWebsCompleted(object sender, SPService.GetAllWebsCompletedEventArgs e)
        {
            ds.allWebs = new List<SPService.WebSiteInfo>();
            ds.allWebs = e.Result.ToList<SPService.WebSiteInfo>();
            //var selectedSite = from web in allWebs where web.SiteName == selectSiteBox.SelectedItem.ToString() select web;
            var siteHeirarchy = from web in ds.allWebs
                                join webParent in ds.allWebs on web.ParentID equals webParent.SiteID
                                orderby web.ParentName == null
                                select web;
            spHeirarchy.ItemsSource = siteHeirarchy;
        }
    }
}
